﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected int nextPage = 1;
    protected int nowPage = 1;
    
    protected StringBuilder sbTableContent = new StringBuilder();
    BLL.Students bllStudent = new BLL.Students();

    private void LoadList(int nPage) 
    {        

        List<MODEL.Students> list = bllStudent.GetAllStudents();
        int index = 1;
        if (list != null)
        {
            foreach (MODEL.Students model in list)
            {
                sbTableContent.Append("<tr><td>" + index.ToString() + "</td>");
                sbTableContent.Append("<td>" + model.SClasses.CName + "</td>");
                sbTableContent.Append("<td>" + model.SLoginName + "</td>");
                sbTableContent.Append("<td>" + model.SCnName + "</td>");
                sbTableContent.Append("<td>" + (model.SGender ? "男" : "女") + "</td>");
                sbTableContent.Append("<td>" + model.STel + "</td>");
                sbTableContent.Append("<td>" + model.SAddtime.ToShortDateString() + "</td>");
                sbTableContent.Append("<td><a href='Modify.aspx?id=" + model.SID.ToString() + "'>修改</a>&nbsp;<a href='javascript:delDo(" + model.SID.ToString() + ")'>删除</a></td></tr>");
                index++;
            }
        }
        else
        {
            LoadList(nPage - 1);
            nowPage--;
        }
        
    }


    protected void Page_Load(object sender, EventArgs e)
    {  
        if (new WebHelper().IsLogin())
        {
            string isJump = Request.QueryString["jump"];
            int jump = 0;
            int nowPage = 0;
             
            
            if (!string.IsNullOrEmpty(isJump))
            {
                if(isJump.Equals("1"))
                {
                    nowPage = int.Parse(Request.QueryString["Page"]);
                    nowPage++;               
                }
                if (isJump.Equals("0"))
                {
                    nowPage = int.Parse(Request.QueryString["Page"]);
                    if (nowPage>1)
                    {
                        nowPage--;   
                    }
                }
                
            }
            LoadList(nowPage); 
        }
        else
        {
            Response.Redirect("login.aspx");
        }
    }


}